maintained constants.
if (swap16_func != nullptr) {
swap16_func(&wpthdr->num);
swap16_func(&wpthdr->next);
- for (int i=0; i<MAXWPT; i++) {
- swap16_func(&wpthdr->idx[i]);
+ for (short &i : wpthdr->idx) {
+ swap16_func(&i);
}
}
}
if (swap16_func != nullptr) {
swap16_func(&rtehdr->num);
swap16_func(&rtehdr->next);
- for (int i=0; i<MAXRTE; i++) {
- swap16_func(&rtehdr->idx[i]);
+ for (short &i : rtehdr->idx) {
+ swap16_func(&i);
}
swap16_func(&rtehdr->rteno);
}
{
if (swap16_func != nullptr) {
swap16_func(&rte->wptnum);
- for (int i=0; i<MAXWPTINRTE; i++) {
- swap16_func(&rte->wptidx[i]);
+ for (short &i : rte->wptidx) {
+ swap16_func(&i);
}
swap16_func(&rte->reserved);
}
swap32_func(&(loghdr->date));
swap32_func(&(loghdr->time));
}
- for (int i = 0; i<MAXTRK; i++) {
- swap_trkhdr(&(loghdr->trkhdr[i]), swap16_func, swap32_func);
+ for (auto &i : loghdr->trkhdr) {
+ swap_trkhdr(&i, swap16_func, swap32_func);
}
}
}
swap_loghdr(&(trldata->loghdr), swap16_func, swap32_func);
- for (int i = 0; i<MAXTRK; i++) {
- swap_trklog(&(trldata->trklog[i]), swap16_func, swap32_func);
+ for (auto &i : trldata->trklog) {
+ swap_trklog(&i, swap16_func, swap32_func);
}
}
ReadGuid(gbfile* f, GUID* guid)
{
guid->l = ReadLong(f);
- for (int i = 0; i < 3; i++) {
- guid->s[i] = ReadShort(f);
+ for (unsigned short &i : guid->s) {
+ i = ReadShort(f);
}
- for (int i = 0; i < 6; i++) {
- guid->c[i] = ReadChar(f);
+ for (unsigned char &i : guid->c) {
+ i = ReadChar(f);
}
}
fatal(MYNAME ": read error");
} else {
// flip bits and check for valid header
- for (int i = 0; i<HEADERRECORDSIZE; i++) {
- header[i] ^= FLIPEDBITS;
+ for (char &i : header) {
+ i ^= FLIPEDBITS;
}
if (memcmp(header, VALIDHEADER, sizeof(VALIDHEADER)-1)) {
fatal(MYNAME ": bad header");
if (gbfread((void*)ttRec, 1, TTRECORDSIZE, fin) != TTRECORDSIZE) {
break;
}
- for (int i = 0; i<TTRECORDSIZE; i++) {
- ttRec[i] ^= FLIPEDBITS;
+ for (char &i : ttRec) {
+ i ^= FLIPEDBITS;
}
// Pick the TT record apart and if it is good, fill in a new Waypoint
static void
fit_rd_deinit()
{
- for (int local_id = 0; local_id<16; local_id++) {
- fit_message_def* def = &fit_data.message_def[local_id];
+ for (auto &local_id : fit_data.message_def) {
+ fit_message_def* def = &local_id;
if (def->fields) {
xfree(def->fields);
def->fields = nullptr;
// int32 GPS_Serial_On_NMEA(const char *port, gpsdevh **fd);
int32 GPS_Serial_Read(gpsdevh* fd, void* ibuf, int size);
int32 GPS_Serial_Write(gpsdevh* fd, const void* obuf, int size);
- int32 GPS_Serial_Write_Packet(gpsdevh* fd, GPS_PPacket& packet);
- int32 GPS_Serial_Send_Ack(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec);
- void GPS_Serial_Error(const char* hdr, ...);
- int32 GPS_Serial_Set_Baud_Rate(gpsdevh* fd, int br);
+
+
+int32 GPS_Serial_Set_Baud_Rate(gpsdevh* fd, int br);
#endif
{
mkshort_handle_imp* h = (mkshort_handle_imp*) xcalloc(sizeof *h, 1);
- for (int i = 0; i < PRIME; i++) {
- QUEUE_INIT(&h->namelist[i]);
+ for (auto &i : h->namelist) {
+ QUEUE_INIT(&i);
}
h->whitespaceok = 1;
return;
}
- for (int i = 0; i < PRIME; i++) {
+ for (auto &i : hdr->namelist) {
queue* e, *t;
- QUEUE_FOR_EACH(&hdr->namelist[i], e, t) {
+ QUEUE_FOR_EACH(&i, e, t) {
uniq_shortname* s = reinterpret_cast<uniq_shortname *>(e);
#if 0
if (global_opts.verbose_status >= 2 && s->conflictctr) {
return color_num;
}
- for (unsigned int i = 0; i < sizeof(color_table) / sizeof(color_table[0]); i++) {
- if (0 == case_ignore_strcmp(opt_color, color_table[i].cn)) {
- return (color_table[i].b << 16) +
- (color_table[i].g << 8) +
- color_table[i].r;
+ for (auto i : color_table) {
+ if (0 == case_ignore_strcmp(opt_color, i.cn)) {
+ return (i.b << 16) +
+ (i.g << 8) +
+ i.r;
}
}
// } else if (nameidx == -1) {
// leave name as a null QString.
} else if (nameidx == -2) {
- for (int oidx=0; oidx<nameindices.size(); oidx++) {
+ for (int nameindice : nameindices) {
// form a compound name from one or more dbf fields.
QString namecomponent = DBFReadStringAttribute(
- ihandledb, iShape, nameindices.at(oidx));
+ ihandledb, iShape, nameindice);
if (!name.isEmpty() && !namecomponent.isEmpty()) {
name.append(QLatin1String(" / "));
}
sscanf(opt_set_location, "%lf:%lf", &lat, &lng);
le_write_double(&MSG_SET_LOCATION[1], lat);
le_write_double(&MSG_SET_LOCATION[9], lng);
- for (unsigned int i = 0; i<sizeof MSG_SET_LOCATION; i++) {
- db(3, "%02x ", MSG_SET_LOCATION[i]);
+ for (unsigned char i : MSG_SET_LOCATION) {
+ db(3, "%02x ", i);
}
db(3, "\n");
if (skytraq_wr_msg_verify((uint8_t*)&MSG_SET_LOCATION, sizeof(MSG_SET_LOCATION)) != res_OK) {
// next three bytes are RGB color, fourth is unknown
// Topo and web uses rrggbb, also need line_color.bbggrr for KML
- for (unsigned xx = 0; xx < 3; xx++) {
+ for (unsigned char &xx : styles[ii].color) {
int col = gbfgetc(tpo_file_in);
if ((col < 0) || (col >255)) {
col = 0; // assign black if out of range 0x00 to 0xff
}
- styles[ii].color[xx] = (uint8_t)col;
+ xx = (uint8_t)col;
}
unsigned char tmp = gbfgetc(tpo_file_in);
static void
disp_v2(ff_vecs_t* v)
{
- for (int i = 0; i < 3; i++) {
- putchar((v->cap[i] & ff_cap_read) ? 'r' : '-');
- putchar((v->cap[i] & ff_cap_write) ? 'w' : '-');
+ for (auto &i : v->cap) {
+ putchar((i & ff_cap_read) ? 'r' : '-');
+ putchar((i & ff_cap_write) ? 'w' : '-');
}
putchar('\t');
}